<?php /* Smarty version 2.6.26, created on 2018-07-27 12:17:39
         compiled from D:%5Citemstudy%5Citem/member%5Ctemplates/xuq/edit.html */ ?>
<style type="text/css"> 
table.etable tr td select{ float:left; }
table.etable tr td em{ font-style:inherit; padding:10px 0 0 10px; color:#FF0000; float:left;}

</style>
<style type="text/css">
.cname{ font-size:16px; border-bottom:1px solid #efefef; width:940px; padding:2px 0 10px 0; float:left; }
.cats_list{ width:780px; height:400px; float:left; overflow:hidden; margin:15px 0 0 70px; border:1px solid #efefef; float:left;}
.cats_list .menu{ width:260px; height:400px; padding:0; overflow-y:scroll; float:left;}
.cats_list .menu ul{}
.cats_list .menu ul li{}
.cats_list .menu ul li a{ width:198px; padding:8px 0 8px 20px; font-size:14px; float:left;}
.cats_list .menu ul li.ch{ padding-right:25px; background: #E5F5FD; float:left; }
.cats_list .menu ul li.ch a{ font-weight:bold; color:#1683B6; }

.addBtton{ width:1880px; text-align:center; padding:10px 0 30px;  float:left;}
.addBtton input{ float:none; margin:20px 0 0 0; padding:8px 38px; border-radius:1px; background: #efefef; color:#666; font-size:16px;} 
.addBtton input.ch{ background: #3399CC; color:#FFFFFF; }

.guize{ width:89px; height:180px; color:#888; border:1px solid #efefef; margin:0 0 30px 18px; padding:10px; line-height:25px; overflow-y:scroll; float:left;}
.guige{width: 880px;background: #eee;padding: 20px;display: none;}
.guige li{height: auto;overflow: hidden;}
table.etable .guige li p{ padding-left: 0;height: auto;overflow: hidden;}
.guige li ol{width: 100%;background: #fff;height: auto;overflow: hidden;margin-bottom: 15px;}
.guige li ol li{float: left;width:150px ;height: 30px;line-height: 30px;}
.guige li ol li input{height: 15px;width: 15px;border: 2px solid #eee;margin:8px 5px 0 5px;display: block;float:left;border-radius: 2px;cursor: pointer;}
.guige li ol li span.chose{background: red;}
.guige li ol li b{float: left;font-weight: normal;}
.guige1 input{    border: 1px solid #DDD;padding: 8px;border-radius: 2px;width: 239px;}
.dg_box_bar{position: absolute;}
.guige2{display: none;}
</style>
<form action="?m=xuq&a=edit_save" method="get">	
<table class="etable">
	<tr>
		<td width="90">需求标题：</td>
		<td><input type="text" name="title" id="title" size="38" value="" placeholder="需求标题"/><em>*</em></td>
	</tr>

	<tr>
		<td>需求商品分类：</td>
		<td>
<div class="lbox"> 

	<div class="cats_list"></div> 
	<input type="hidden" name="m" value="goods"/>
	<input type="hidden" name="uid" id="cid" value="<?php if ($_GET['cid']): ?><?php echo $_GET['cid']; ?>
<?php endif; ?>"/>
	<input type="hidden" name="a" value="edit"/>
	<?php if ($_GET['gid']): ?>
		<input type="hidden" name="id" id="gid" value="<?php echo $_GET['gid']; ?>
"/>
	<?php endif; ?>
	

</div></td>
	</tr>
	<tr class="guige2">
			<td style="padding-top:10px;" valign="top">规格：</td>
			<td>
				<ul class="guige">
					
				</ul>
				<div class="guige1">
					
				</div>
			</td> 
		</tr>
	<tr>宝贝销售规格</tr>
	<tr>
	
	</tr>
	<tr style=" display:none" class="ys">
	
		<td >颜色</td>
		<td><a class="ys2"></a> 数量：<input type="text" name="sl1" id="sl1" value="" style="float:inherit" /></td>
	</tr>	
    	<tr style=" display:none" class="cm">
		<td>尺码</td>
		<td><a class="chima"></a> 数量：<input type="text" name="sl2" id="sl2" value="" style="float:inherit"/></td>
	</tr>	
    	<tr style=" display:none" class="hb1">
		<td>厚薄</td>
		<td> <a class="hb"></a>：数量<input type="text" name="sl3" id="sl3" value="" style="float:inherit"/></td>
	</tr>	
	<tr>
		<td>备注：</td>
		<td  >

		<input type="text" name="" id="bz" size="38"  value="" placeholder="备注"/>
		<input type="hidden" name="fl" id="fl" />
        <input type="hidden" name="ys3" id="ys3" />
        <input type="hidden" name="cm3" id="cm3" />
        <input type="hidden" name="hb3" id="hb3" />
        </td>
	</tr>
<input type="checkbox" checked="unchecked" name="" id="" value="" />
</table> 
</form> 
<script type="text/javascript">
$(function(){
	$(document).on("click",".menu ul li a",function(){
		var $this = $(this);
 		var cid = $this.attr('data-cid'); 
		$this.parent('li').addClass('ch').siblings().removeClass('ch');
		$this.parents('.menu').nextAll().remove();
		category_next(cid);
 	}); 
	function category_next(pcid){ 
		cid = cid?cid:'0';
		$.post('member.php?m=xuq&a=ajax_get_next_list',{pcid:pcid}, function(result){
			var data = jQuery.parseJSON(result);
			if(data.error == '0'){
				if(data.last == '0'){
					html = '<div class="menu menu_'+cid+'"><ul>';
					$.each(data.category, function(key, val){
						html += '<li><a href="javascript:;" data-cid="'+val.cid+'" >'+val.name+'</a></li>'; 
					});
					html += '<ul></div>';
					if($('.menu').length == 0){ 
						$('.cats_list').html(html);		
					}else{
					
						$('.menu:last').after(html);		
					} 
					$("#cid").val('');
					$("#submit_cats").attr('disabled',true).removeClass('ch');
						
						
						
				}else{
					$('.guige2').show();
					$("#cid").val(pcid);
					$("#submit_cats").attr('disabled',false).addClass('ch'); 
					
					$.post('member.php?m=xuq&a=ajax_get_gg',{pcid:pcid}, function(result){
						var data = jQuery.parseJSON(result);
						
						if(data==null){
						$('.guige').hide();
						$('.guige1').show();
							html="";
							html+='<input type="text" class="" name="goods_guige2" id="goods_guige2" placeholder="请输入规格"/>'
							$('.guige1').html(html);
						}else if(data.error == '0'){
							$('.guige1').hide();
							$('.guige').show();
							var a = data.category;
							html = "";
							for(var i=0;i<a.length;i++){
								html+='<li><p>'+a[i].yiji.name+'</p><ol>'
								
								for(var k=0;k<a[i].yiji.erji.length;k++){
									var b = a[i].yiji.erji;
									html+='<li class="allchose"><input type="checkbox" class="asd'+i+'" uid="'+b[k].id+'" uname="'+b[k].name+'" ></span><b>'+ b[k].name +'</b></li>';
								}
								
								
								html+='</ol></li>'
							}
							$('.guige').html(html);
	
							var a = data.category;
							
						
							var select0 = $(".asd0");
								
								for( var o0=0;o0<select0.length;o0++){
									
									select0[o0].onclick = function(){
										var ys4="颜色,"+$(this).attr("uname");
										$(".ys2").html($(this).attr("uname"));
										$(".ys").show();
										$("#ys3").val(ys4);
										for(var p0 = 0;p0<o0;p0++){
											
											select0[p0].checked = false;
										}
										this.checked = true;
									}
								}
								
								var select1 = $(".asd1");
								
								for( var o1=0;o1<select1.length;o1++){
								
									select1[o1].onclick = function(){
										var cm4="尺码,"+$(this).attr("uname");
									
										$(".chima").html($(this).attr("uname"));
										$(".cm").show();
										$("#cm3").val(cm4);
										for(var p1 = 0;p1<o1;p1++){
											
											select1[p1].checked = false;
										}
										this.checked = true;
									}
								}
								
							var select2 = $(".asd2");
								
								for( var o2=0;o2<select2.length;o2++){
									
									select2[o2].onclick = function(){
										var hb4="厚薄,"+$(this).attr("uname");
										
										$(".hb").html($(this).attr("uname"));
										$(".hb1").show();
										$("#hb3").val(hb4);
										for(var p2 = 0;p2<o2;p2++){
											
											select2[p2].checked = false;
										}
										this.checked = true;
									}
								}
								
							
							/*for(var i=0;i<$('.types').length;i++){
								var d= $('.types');
								
								d[i].onclick = function(){
//									this.checked = false;
									alert($(this).html())
									for(var k=0;k<i;k++){
										if(d[k].checked= false){
											alert(1)
										}
										
									}
								}
							}*/
							
							shiftjoin();
						}
						
					});
//					alert(pcid);
				} 
			}else{
				alert('系统繁忙');
			}
		}); 
	}
	
	var danchose = function(){
		var a = $(".allchose>span");
		
		
		
		
	}
	
	var shiftjoin = function (){
		var a = $(".allchose>span");
		var e =[];
		for(var i=0;i<a.length;i++)
		a[i].onclick = function(){
			var b = $(this).attr("uid");
			if($(this).hasClass('chose')){
				$(this).removeClass('chose');
				e.shift(b)
			}
			else{
				$(this).addClass('chose');
				e.push(b);
			}
			
			//alert(e);
			
		}
	}
	
	
	<?php if ($_GET['cid']): ?>
		$.post("member.php?m=goods&a=ajax_get_parents_list",{cid:'<?php echo $_GET['cid']; ?>
'},function(result){ 
			var data = jQuery.parseJSON(result); 
			html = '';
			$(data).each(function(key, val){
				html += '<div class="menu"><ul>';
				$.each(val.list, function(index, obj){
					if(obj.cid == val.cid){
						html += '<li class="ch"><a href="javascript:;" data-cid="'+obj.cid+'">'+obj.name+'</a></li>'; 
					}else{
						html += '<li><a href="javascript:;" data-cid="'+obj.cid+'" >'+obj.name+'</a></li>'; 
					} 
				}); 
				html += '<ul></div>'; 
			});
			$('.cats_list').html(html); 
		});
		$("#cid").val('<?php echo $_GET['cid']; ?>
'); 
		$("#submit_cats").attr('disabled',false).addClass('ch'); 
		
	<?php else: ?>
		category_next('0');	
	<?php endif; ?> 
});
</script>


<script type="text/javascript" src="<?php echo $this->_tpl_vars['__PUBLIC__']; ?>
js/area.js"></script>


<script type="text/javascript">
	<?php if ($this->_tpl_vars['row']['prov'] == '' && $this->_tpl_vars['row']['city'] == '' && $this->_tpl_vars['row']['dist'] == ''): ?>
		$(".area_box").area();
	<?php else: ?>
		$(".area_box").area({ 
			'prov':'<?php echo $this->_tpl_vars['row']['prov1']; ?>
',
			'city':'<?php echo $this->_tpl_vars['row']['city']; ?>
',
			'dist':'<?php echo $this->_tpl_vars['row']['dist']; ?>
'
		});	
	<?php endif; ?> 
	function ajax_submit(){ 
		var name = $("#title").val(); 		if(name == '')	{ 	alert('标题不能为空！');	return false; }

		var mobile = $("#cid").val();		if(mobile == ''){ 	alert('选择产品分类');	return false; }

		var bz = $("#bz").val();	if(bz == ''){ 	alert('备注不能为空！');	return false; } 
	var sl = $("#sl1").val();	if($("#sl1").val() == ''){ 	alert('颜色数量不能为空！');	return false; }
	
	if($("#sl2").val()!=""){
	 sl += ","+$("#sl2").val();
	}
	if($("#sl3").val()!=""){
	 sl += ","+$("#sl3").val(); 
	}
	
	var gg = $("#ys3").val();
	if($("#cm3").val()!=""){
	gg += ";"+$("#cm3").val();
	}
	if($("#hb3").val()!=""){
	gg += ";"+$("#hb3").val();
	}

		var is_default = $("#recive_is_default").is(':checked')?'1':'0'; 
	
		$.post('member.php?m=xuq&a=edit_save',{name:name,mobile:mobile,bz:bz,sl:sl,gg:gg},function(result){ 
			var data = jQuery.parseJSON(result); 
			if(data.error =='0'){
				ajax_close();
				$.alert(data.msg);
				$.alert('保存成功', function(){
					location.reload(); 
				});
			}else{
				
			} 
		}); 
	}
</script>